package com.initialize.service.system.feign;


import com.baomidou.mybatisplus.extension.api.R;
import com.initialize.commom.config.path.ServiceApiConfig;
import com.initialize.common.mybatis.plus.entity.User;
import com.initialize.common.mybatis.plus.service.impl.UserServiceImpl;
import com.initialize.service.api.system.feign.IUserClient;
import com.initialize.service.system.service.UserService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 用户服务Feign实现类
 *
 * @author Chill
 */
@Slf4j
@RestController
@RequestMapping(ServiceApiConfig.USER_API_PREFIX)
public class UserClient implements IUserClient {

    UserServiceImpl iUserService;

    final
    UserService userService;

    public UserClient(UserServiceImpl iUserService, UserService userService) {
        this.iUserService = iUserService;
        this.userService = userService;
    }

    @Override
    @GetMapping("/user-info/{id}")
    public R<User> userInfo(@PathVariable Long id) {
        return R.ok(iUserService.getById(id));
    }


    @Override
    @ApiOperation(value = "客户端--用户登录", notes = "用户登录")
    @PostMapping("/login")
    public User login(@RequestBody String username) {
        return userService.selectLoginAndPsd(username);
    }

}
